;Assembler header file for PCI
;written by DefMod (Dec 31 2005) on Sat Dec 31 14:03:54 2005
;Tom Hughes, tom@compton.nu, 21 Dec 2002

        [       :LNOT: :DEF: PCI_Hdr
        GBLS    PCI_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

;Symbols for constants
PCI_VendorID                    *       &FFFF
PCI_VendorIDShift               *       0
PCI_DeviceID                    *       &FFFF0000
PCI_DeviceIDShift               *       16
PCI_AnyID                       *       &FFFFFFFF
PCI_ByteAccess                  *       &1
PCI_HalfWordAccess              *       &2
PCI_WordAccess                  *       &4
PCI_MemoryReadPrefetchable      *       &8
PCI_HardwareAddressAccessReadWrite *       &0
PCI_HardwareAddressAccessReadOnly *       &1
PCI_HardwareAddressAccessNone   *       &2
PCI_HardwareAddressAccess       *       &F
PCI_HardwareAddressAccessShift  *       0
PCI_HardwareAddressBufferable   *       &10
PCI_HardwareAddressCacheable    *       &20
PCI_HardwareAddressAccessSet    *       &200
PCI_HardwareAddressQueryOnly    *       &80000000
PCI_HardwareAddressIsIO         *       &1
PCI_HardwareAddressPrefetchable *       &8
PCI_ReadInfoDeviceNumber        *       &1
PCI_ReadInfoFunctionNumber      *       &1
PCI_ReadInfoBusNumber           *       &2
PCI_ReadInfoParentBridgeHandle  *       &4
PCI_ReadInfoSlotNumber          *       &8
PCI_ReadInfoID                  *       &10
PCI_ReadInfoRevisionID          *       &20
PCI_ReadInfoSubsystemID         *       &40
PCI_ReadInfoClass               *       &80
PCI_ReadInfoCMOSAddress         *       &100
PCI_ReadInfoCMOSSize            *       &200
PCI_ReadInfoDescription         *       &400
PCI_ReadInfoDeviceVectorNumber  *       &800
PCI_ReadInfoEthernetAddressLow  *       &1000
PCI_ReadInfoEthernetAddressHigh *       &2000
PCI_ReadInfoLogicalDMAChannel   *       &4000
PCI_ReadInfoVendorDescription   *       &8000
PCI_LogicalAddressBufferable    *       &10
PCI_LogicalAddressIsIO          *       &40000000

;Symbols for structure offsets and sizes
                                ^       0
                                #       Bits
PCI_ID                          *       @

                                ^       0
                                #       Int
PCI_Class                       *       @

                                ^       0
                                #       Int
PCI_Function                    *       @

PCI_AccessSize                  *       4 ;abstract type
PCI_Address                     *       4 ;abstract type
PCI_ConfigurationAddress        *       4 ;abstract type
                                ^       0
                                #       Bits
PCI_MemoryReadFlags             *       @

                                ^       0
                                #       Bits
PCI_MemoryWriteFlags            *       @

                                ^       0
                                #       Bits
PCI_ReadInfoFlags               *       @

                                ^       0
                                #       Bits
PCI_HardwareAddressInputFlags   *       @

                                ^       0
                                #       Bits
PCI_HardwareAddressOutputFlags  *       @

                                ^       0
                                #       Bits
PCI_LogicalAddressFlags         *       @


;Symbols for SWI's and SWI reason codes
XPCI_ReturnNumber               *       &70382
PCI_ReturnNumber                *       &50382
   ;Exit
   ;  R0 = used (PCI_Function)

XPCI_SpecialCycle               *       &7038C
PCI_SpecialCycle                *       &5038C
   ;Entry
   ;  R0 = bus (Int)
   ;  R1 -> message (data)

XPCI_FindByLocation             *       &7038D
PCI_FindByLocation              *       &5038D
   ;Entry
   ;  R0 = bus (Int)
   ;  R1 = device_or_function (Int)
   ;Exit
   ;  R3 = function (PCI_Function)

XPCI_FindByID                   *       &7038E
PCI_FindByID                    *       &5038E
   ;Entry
   ;  R0 = vendor_id (PCI_ID)
   ;  R1 = device_id (PCI_ID)
   ;  R2 = subsystem_vendor_id (PCI_ID)
   ;  R3 = previous_function (PCI_Function)
   ;  R4 = subsystem_id (PCI_ID)
   ;Exit
   ;  R3 = function (PCI_Function)

XPCI_FindByClass                *       &7038F
PCI_FindByClass                 *       &5038F
   ;Entry
   ;  R0 = pciclass (PCI_Class)
   ;  R1 = class_mask (PCI_Class)
   ;  R3 = previous_function (PCI_Function)
   ;Exit
   ;  R3 = function (PCI_Function)

XPCI_RAMAlloc                   *       &70390
PCI_RAMAlloc                    *       &50390
   ;Entry
   ;  R0 = size (Int)
   ;  R1 = alignment (Int)
   ;  R2 = boundary_limitation (Int)
   ;Exit
   ;  R0 = logical_address (pointer to data)
   ;  R1 = pci_address (PCI_Address)

XPCI_RAMFree                    *       &70391
PCI_RAMFree                     *       &50391
   ;Entry
   ;  R0 = logical_address (pointer to data)

XPCI_LogicalAddress             *       &70392
PCI_LogicalAddress              *       &50392
   ;Entry
   ;  R0 = flags (PCI_LogicalAddressFlags)
   ;  R1 = pci_address (PCI_Address)
   ;  R2 = length (Int)
   ;Exit
   ;  R4 = logical_address (pointer to data)

Service_PCILookupDescription    *       &0
   ;Entry
   ;  R1 = &C3
   ;  R2 = &0
   ;  R3 = function (PCI_Function)
   ;Exit
   ;  R1 = unclaimed (Bool)
   ;  R2 -> description (Char)

Service_PCILookupVendorDescription *       &1
   ;Entry
   ;  R0 = vendir (PCI_ID)
   ;  R1 = &C3
   ;  R2 = &1
   ;Exit
   ;  R1 = unclaimed (Bool)
   ;  R2 -> description (Char)

        ]
        END
